package com.example.springbootschedule.job;

import com.example.springbootschedule.common.config.RedisConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;

@Configuration
@Slf4j
public class RedisJob {

    @Autowired
    private RedisConfig redisConfig;

    @Scheduled(cron = "0/10 * * * * ?")
    public void jobExec1() {
        if (redisConfig.getlock("jobExec1", 11)) {
            log.info("redisjob1 取得锁开始执行！！！！{}", LocalDateTime.now());
        }
    }

    @Scheduled(cron = "0/10 * * * * ?")
    public void jobExec2() {
        if (redisConfig.getlock("jobExec2", 11)) {
            log.info("redisjob2 取得锁开始执行！！！！{}", LocalDateTime.now());
        }
    }
}
